home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / aminet / mus / play / multiplsr.lha / trekplay.asm < prev    next >
Assembly Source File  |  1992-09-14  |  15KB  |  809 lines

  1. * MultiPlayer
  2. * Copyright (C) 1992 Bryan Ford
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. *
  18. * I (the author of MultiPlayer) can be contacted on the Internet at
  19. * "bryan.ford@m.cc.utah.edu".  See "Player.doc" for other addresses.
  20. *
  21. * Note:  This playroutine was not originally written by me.  In general
  22. * these playroutines are public domain, so I am bringing the versions
  23. * modified for MultiPlayer under the General Public License.  In the
  24. * few cases of already-copyrighted playroutines, the above copyright
  25. * notice applies only to the parts of the file written by me.
  26. *
  27. * $Id: trekplay.asm,v 4.1 92/06/21 11:15:06 BAF Exp Locker: BAF $
  28. *
  29.  
  30.     include "player.i"
  31.  
  32.     xref    modmem,modend,suppmem
  33.     xref    getfreqmodspeed,ntgetsongname,ntgetsongauthor,dmawait
  34.  
  35.     xdef    trekstart
  36.  
  37.     code    text
  38.  
  39. trekstart:
  40.     plstartret 9$
  41.  
  42.         cnop    0,4
  43.     dc.l    gmod_Hook
  44. 9$    gmodnop
  45.     gmodbra    2$            ; StartMusic
  46.     gmodnop
  47.     gmodnop
  48.     gmodnop
  49.     gmodq    1            ; ContinueMusic
  50.     gmodnop
  51.     gmodnop
  52.     gmodnop
  53.     gmodnop
  54.     gmodnop
  55.     gmodnop
  56.     gmodnop
  57.     gmodbra    ntgetsongname        ; GetSongName
  58.     gmodbra    ntgetsongauthor        ; GetSongAuthor
  59.     gmodbra    getfreqmodspeed        ; GetFrequency
  60.     gmodbra    7$            ; TimerTick
  61.     lea    name(pc),a0        ; GetMakerName
  62.     move.l    a0,d0
  63.     rts
  64.  
  65. 2$    movem.l    d2-d7/a2-a6,-(sp)
  66.     move.l    suppmem,a0
  67.     bsr    trek_init
  68.     movem.l    (sp)+,d2-d7/a2-a6
  69.     rts
  70.  
  71. 7$    movem.l    d2-d7/a2-a6,-(sp)
  72.     bsr    trek_music
  73.     movem.l    (sp)+,d2-d7/a2-a6
  74.     rts
  75.  
  76.  
  77. ; STARTREKKER 1.2      AM REPLAYROUTINE
  78. ;
  79. ; BY BJOERN WESEN / EXOLON OF FAIRLIGHT
  80.  
  81.  
  82. ; Call mt_init, then mt_music each frame, call mt_end to stop
  83.  
  84. ; NOTE! The mt_amwaveforms have to reside in CHIPMEM! Therefore the ORG
  85. ;       below...
  86.  
  87.  
  88. trek_init:
  89. mt_init    adda.w    #24,a0            ; Store the pointer to data2 (a0)
  90.     move.l    a0,mt_data2pt
  91.  
  92.     move.l    modmem,a0
  93.     move.l    modend,a3
  94.     subq.l    #4,a3
  95.  
  96.     lea    $3b8(a0),a1
  97.     moveq    #$7f,d0
  98.     moveq    #0,d2
  99.     moveq    #0,d1
  100. mt_lop2    move.b    (a1)+,d1
  101.     cmp.b    d2,d1
  102.     ble.s    mt_lop
  103.     move.l    d1,d2
  104. mt_lop    dbf    d0,mt_lop2
  105.     addq.b    #1,d2
  106.  
  107.     asl.l    #8,d2
  108.     asl.l    #2,d2
  109.     lea    4(a1,d2.l),a2
  110.     lea    mt_samplestarts(pc),a1
  111.     add.w    #42,a0
  112.     moveq    #$1e,d0
  113. mt_lop3    cmp.l    a2,a3
  114.     blt.s    1$
  115.     clr.l    (a2)
  116. 1$    move.l    a2,(a1)+
  117.     moveq    #0,d1
  118.     move.w    (a0),d1
  119.     clr.b    2(a0)
  120.     asl.l    #1,d1
  121.     add.l    d1,a2
  122.     add.l    #30,a0
  123.     dbf    d0,mt_lop3
  124.  
  125.     or.b    #2,$bfe001
  126.     move.b    #6,mt_speed
  127.     moveq    #0,d0
  128.     lea    $dff000,a0
  129.     move.w    d0,$a8(a0)
  130.     move.w    d0,$b8(a0)
  131.     move.w    d0,$c8(a0)
  132.     move.w    d0,$d8(a0)
  133.     clr.b    mt_songpos
  134.     clr.b    mt_counter
  135.     clr.w    mt_pattpos
  136.     rts
  137.  
  138. trek_music:
  139. mt_music
  140.     move.l    modmem,a0
  141.     addq.b    #1,mt_counter
  142.     move.b    mt_counter(pc),d0
  143.     cmp.b    mt_speed(pc),d0
  144.     blt    mt_nonew
  145.     clr.b    mt_counter
  146.  
  147.     move.l    modmem,a0
  148.     lea    $c(a0),a3
  149.     lea    $3b8(a0),a2
  150.     lea    $43c(a0),a0
  151.  
  152.     moveq    #0,d0
  153.     moveq    #0,d1
  154.     move.b    mt_songpos(pc),d0
  155.     move.b    0(a2,d0.w),d1
  156.     lsl.w    #8,d1
  157.     lsl.w    #2,d1
  158.     add.w    mt_pattpos(pc),d1
  159.     clr.w    mt_dmacon
  160.  
  161.     lea    $dff0a0,a5
  162.     lea    mt_voice1(pc),a4
  163.     bsr    mt_playvoice
  164.     addq.l    #4,d1
  165.     lea    $dff0b0,a5
  166.     lea    mt_voice2(pc),a4
  167.     bsr    mt_playvoice
  168.     addq.l    #4,d1
  169.     lea    $dff0c0,a5
  170.     lea    mt_voice3(pc),a4
  171.     bsr    mt_playvoice
  172.     addq.l    #4,d1
  173.     lea    $dff0d0,a5
  174.     lea    mt_voice4(pc),a4
  175.     bsr    mt_playvoice
  176.  
  177.     bsr    mt_wait
  178.     move.w    mt_dmacon(pc),d0
  179.     or.w    #$8000,d0
  180.     move.w    d0,$dff096
  181.     bsr    mt_wait
  182. mt_nodma
  183.     lea    $dff000,a3
  184.     lea    mt_voice1(pc),a4
  185.     move.l    $a(a4),$a0(a3)
  186.     move.w    $e(a4),$a4(a3)
  187.     tst.w    30(a4)
  188.     bne.s    mt_nov1
  189.     move.w    $12(a4),$a8(a3)
  190. mt_nov1    lea    mt_voice2(pc),a4
  191.     move.l    $a(a4),$b0(a3)
  192.     move.w    $e(a4),$b4(a3)
  193.     tst.w    30(a4)
  194.     bne.s    mt_nov2
  195.     move.w    $12(a4),$b8(a3)
  196. mt_nov2    lea    mt_voice3(pc),a4
  197.     move.l    $a(a4),$c0(a3)
  198.     move.w    $e(a4),$c4(a3)
  199.     tst.w    30(a4)
  200.     bne.s    mt_nov3
  201.     move.w    $12(a4),$c8(a3)
  202. mt_nov3    lea    mt_voice4(pc),a4
  203.     move.l    $a(a4),$d0(a3)
  204.     tst.w    30(a4)
  205.     bne.s    mt_nov4
  206.     move.w    $e(a4),$d4(a3)
  207.     move.w    $12(a4),$d8(a3)
  208.  
  209. mt_nov4    add.w    #$10,mt_pattpos
  210.     cmp.w    #$400,mt_pattpos
  211.     bne.s    mt_exit
  212. mt_next    clr.w    mt_pattpos
  213.     clr.b    mt_break
  214.     move.l    modmem,a0
  215.     addq.b    #1,mt_songpos
  216.     and.b    #$7f,mt_songpos
  217.     move.b    $3b6(a0),d0
  218.     cmp.b    mt_songpos(pc),d0
  219.     bne.s    mt_exit
  220.     move.b    $3b7(a0),mt_songpos
  221. mt_exit    tst.b    mt_break
  222.     bne.s    mt_next
  223.     bra    mt_amhandler
  224.  
  225. mt_wait    jsr     dmawait
  226.  
  227. mt_nonew
  228.     lea    mt_voice1(pc),a4
  229.     lea    $dff0a0,a5
  230.     bsr    mt_com
  231.     lea    mt_voice2(pc),a4
  232.     lea    $dff0b0,a5
  233.     bsr    mt_com
  234.     lea    mt_voice3(pc),a4
  235.     lea    $dff0c0,a5
  236.     bsr    mt_com
  237.     lea    mt_voice4(pc),a4
  238.     lea    $dff0d0,a5
  239.     bsr    mt_com
  240.     bra.s    mt_exit
  241.  
  242. mt_mulu
  243.     dc.w    0,$1e,$3c,$5a,$78,$96,$b4,$d2,$f0,$10e,$12c,$14a
  244.     dc.w    $168,$186,$1a4,$1c2,$1e0,$1fe,$21c,$23a,$258,$276
  245.     dc.w    $294,$2b2,$2d0,$2ee,$30c,$32a,$348,$366,$384,$3a2
  246.  
  247. mt_playvoice
  248.     move.l    0(a0,d1.l),(a4)
  249.     moveq    #0,d2
  250.     move.b    2(a4),d2
  251.     lsr.b    #4,d2
  252.     move.b    (a4),d0
  253.     and.b    #$f0,d0
  254.     or.b    d0,d2
  255.     beq    mt_oldinstr
  256.  
  257.     lea    mt_samplestarts-4(pc),a1
  258.     move.w    d2,34(a4)
  259.     move.w    d2,d0
  260.     mulu    #120,d0
  261.     add.l    mt_data2pt,d0
  262.     move.l    a0,-(sp)
  263.     move.l    d0,a0
  264.     clr.w    30(a4)
  265.     cmp.w    #'AM',(a0)
  266.     bne.s    mt_noa9
  267.     move.w    6(a0),d0
  268.     lsr.w    #2,d0
  269.     st    30(a4)
  270. mt_noa9    move.l    (sp)+,a0
  271.  
  272.     asl.w    #2,d2
  273.     move.l    0(a1,d2.l),4(a4)
  274.     lsr.w    #2,d2
  275.     mulu    #30,d2
  276.     move.w    0(a3,d2.w),8(a4)
  277.     tst.w    30(a4)
  278.     beq.s    mt_noa8
  279.     move.w    d0,$12(a4)
  280.     bra.s    mt_noa7
  281. mt_noa8    move.w    2(a3,d2.w),$12(a4)
  282. mt_noa7    moveq    #0,d3
  283.     move.w    4(a3,d2.w),d3
  284.     tst.w    d3
  285.     beq.s    mt_noloop
  286.     move.l    4(a4),d0
  287.     asl.w    #1,d3
  288.     add.l    d3,d0
  289.     move.l    d0,$a(a4)
  290.     move.w    4(a3,d2.w),d0
  291.     add.w    6(a3,d2.w),d0
  292.     move.w    d0,8(a4)
  293.     bra.s    mt_hejaSverige
  294. mt_noloop
  295.     move.l    4(a4),d0
  296.     add.l    d3,d0
  297.     move.l    d0,$a(a4)
  298. mt_hejaSverige
  299.     move.w    6(a3,d2.w),$e(a4)
  300.  
  301. mt_oldinstr
  302.     move.w    (a4),d0
  303.     and.w    #$fff,d0
  304.     beq    mt_com2
  305.     tst.w    30(a4)
  306.     bne.s    mt_rambo
  307.     tst.w    8(a4)
  308.     beq    mt_stopsound
  309.     tst.b    $12(a4)
  310.     bne    mt_stopsound
  311.     move.b    2(a4),d0
  312.     and.b    #$f,d0
  313.     cmp.b    #5,d0
  314.     beq    mt_setport
  315.     cmp.b    #3,d0
  316.     beq    mt_setport
  317.  
  318. mt_rambo
  319.     move.w    (a4),$10(a4)
  320.     and.w    #$fff,$10(a4)
  321.     move.w    $1a(a4),$dff096
  322.     clr.b    $19(a4)
  323.  
  324.     tst.w    30(a4)
  325.     beq.s    mt_noaminst
  326.     move.l    a0,-(sp)
  327.     move.w    34(a4),d0
  328.     mulu    #120,d0
  329.     add.l    mt_data2pt,d0
  330.     move.l    d0,a0
  331.     moveq    #0,d0
  332.     move.w    26(a0),d0
  333.     lsl.w    #5,d0
  334.     add.l    #mt_amwaveforms,d0
  335.     move.l    d0,(a5)
  336.     move.w    #16,4(a5)
  337.     move.l    d0,$a(a4)
  338.     move.w    #16,$e(a4)
  339.     move.w    6(a0),32(a4)
  340.     move.l    #1,36(a4)
  341.     move.w    34(a0),d0
  342.     move.w    d1,-(sp)
  343.     move.w    $10(a4),d1
  344.     lsl.w    d0,d1
  345.     move.w    d1,$10(a4)
  346.     move.w    d1,6(a5)
  347.     move.w    (sp)+,d1
  348.     move.l    (sp)+,a0
  349.     bra.s    mt_juck
  350.  
  351. mt_noaminst
  352.     move.l    4(a4),(a5)
  353.     move.w    8(a4),4(a5)
  354.     move.w    $10(a4),6(a5)
  355.  
  356. mt_juck    move.w    $1a(a4),d0
  357.     or.w    d0,mt_dmacon
  358.     bra    mt_com2
  359.  
  360. mt_stopsound
  361.     move.w    $1a(a4),$dff096
  362.     bra    mt_com2
  363.  
  364. mt_setport
  365.     move.w    (a4),d2
  366.     and.w    #$fff,d2
  367.     move.w    d2,$16(a4)
  368.     move.w    $10(a4),d0
  369.     clr.b    $14(a4)
  370.     cmp.w    d0,d2
  371.     beq.s    mt_clrport
  372.     bge    mt_com2
  373.     move.b    #1,$14(a4)
  374.     bra    mt_com2
  375. mt_clrport
  376.     clr.w    $16(a4)
  377.     rts
  378.  
  379. mt_port    move.b    3(a4),d0
  380.     beq.s    mt_port2
  381.     move.b    d0,$15(a4)
  382.     clr.b    3(a4)
  383. mt_port2
  384.     tst.w    $16(a4)
  385.     beq.s    mt_rts
  386.     moveq    #0,d0
  387.     move.b    $15(a4),d0
  388.     tst.b    $14(a4)
  389.     bne.s    mt_sub
  390.     add.w    d0,$10(a4)
  391.     move.w    $16(a4),d0
  392.     cmp.w    $10(a4),d0
  393.     bgt.s    mt_portok
  394.     move.w    $16(a4),$10(a4)
  395.     clr.w    $16(a4)
  396. mt_portok
  397.     move.w    $10(a4),6(a5)
  398. mt_rts    rts
  399.  
  400. mt_sub    sub.w    d0,$10(a4)
  401.     move.w    $16(a4),d0
  402.     cmp.w    $10(a4),d0
  403.     blt.s    mt_portok
  404.     move.w    $16(a4),$10(a4)
  405.     clr.w    $16(a4)
  406.     move.w    $10(a4),6(a5)
  407.     rts
  408.  
  409. mt_sin    dc.b    0,$18,$31,$4a,$61,$78,$8d,$a1,$b4,$c5,$d4,$e0,$eb,$f4
  410.     dc.b    $fa,$fd
  411.     dc.b    $ff,$fd,$fa,$f4,$eb,$e0,$d4,$c5,$b4,$a1,$8d,$78,$61
  412.     dc.b    $4a,$31,$18
  413.  
  414. mt_vib    move.b    $3(a4),d0
  415.     beq.s    mt_vib2
  416.     move.b    d0,$18(a4)
  417.  
  418. mt_vib2    move.b    $19(a4),d0
  419.     lsr.w    #2,d0
  420.     and.w    #$1f,d0
  421.     moveq    #0,d2
  422.     move.b    mt_sin(pc,d0.w),d2
  423.     move.b    $18(a4),d0
  424.     and.w    #$f,d0
  425.     mulu    d0,d2
  426.     lsr.w    #7,d2
  427.     move.w    $10(a4),d0
  428.     tst.b    $19(a4)
  429.     bmi.s    mt_vibsub
  430.     add.w    d2,d0
  431.     bra.s    mt_vib3
  432. mt_vibsub
  433.     sub.w    d2,d0
  434. mt_vib3    move.w    d0,6(a5)
  435.     move.b    $18(a4),d0
  436.     lsr.w    #2,d0
  437.     and.w    #$3c,d0
  438.     add.b    d0,$19(a4)
  439.     rts
  440.  
  441. mt_arplist
  442.     dc.b    0,1,2,0,1,2,0,1,2,0,1,2,0
  443.     dc.b    1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1
  444.  
  445. mt_arp    moveq    #0,d0
  446.     move.b    mt_counter(pc),d0
  447.     move.b    mt_arplist(pc,d0.w),d0
  448.     beq.s    mt_arp0
  449.     cmp.b    #2,d0
  450.     beq.s    mt_arp2
  451. mt_arp1    moveq    #0,d0
  452.     move.b    3(a4),d0
  453.     lsr.b    #4,d0
  454.     bra.s    mt_arpdo
  455. mt_arp2    moveq    #0,d0
  456.     move.b    3(a4),d0
  457.     and.b    #$f,d0
  458. mt_arpdo
  459.     asl.w    #1,d0
  460.     move.w    $10(a4),d1
  461.     and.w    #$fff,d1
  462.     lea    mt_periods(pc),a0
  463.     moveq    #$24,d2
  464. mt_arp3    cmp.w    (a0)+,d1
  465.     bge.s    mt_arpfound
  466.     dbf    d2,mt_arp3
  467. mt_arp0    move.w    $10(a4),6(a5)
  468.     rts
  469. mt_arpfound
  470.     move.w    -2(a0,d0.w),6(a5)
  471.     rts
  472.  
  473. mt_normper
  474.     move.w    $10(a4),6(a5)
  475.     rts
  476.  
  477. mt_com    move.w    2(a4),d0
  478.     and.w    #$fff,d0
  479.     beq.s    mt_normper
  480.     move.b    2(a4),d0
  481.     and.b    #$f,d0
  482.     tst.b    d0
  483.     beq.s    mt_arp
  484.     cmp.b    #1,d0
  485.     beq.s    mt_portup
  486.     cmp.b    #2,d0
  487.     beq.s    mt_portdown
  488.     cmp.b    #3,d0
  489.     beq    mt_port
  490.     cmp.b    #4,d0
  491.     beq    mt_vib
  492.     cmp.b    #5,d0
  493.     beq.s    mt_volport
  494.     cmp.b    #6,d0
  495.     beq.s    mt_volvib
  496.     move.w    $10(a4),6(a5)
  497.     cmp.b    #$a,d0
  498.     beq.s    mt_volslide
  499.     rts
  500.  
  501. mt_portup
  502.     moveq    #0,d0
  503.     move.b    3(a4),d0
  504.     sub.w    d0,$10(a4)
  505.     move.w    $10(a4),d0
  506.     cmp.w    #$71,d0
  507.     bpl.s    mt_portup2
  508.     move.w    #$71,$10(a4)
  509. mt_portup2
  510.     move.w    $10(a4),6(a5)
  511.     rts
  512.  
  513. mt_portdown
  514.     moveq    #0,d0
  515.     move.b    3(a4),d0
  516.     add.w    d0,$10(a4)
  517.     move.w    $10(a4),d0
  518.     cmp.w    #$358,d0
  519.     bmi.s    mt_portdown2
  520.     move.w    #$358,$10(a4)
  521. mt_portdown2
  522.     move.w    $10(a4),6(a5)
  523.     rts
  524.  
  525. mt_volvib
  526.      bsr    mt_vib2
  527.      bra.s    mt_volslide
  528. mt_volport
  529.      bsr    mt_port2
  530.  
  531. mt_volslide
  532.     moveq    #0,d0
  533.     move.b    3(a4),d0
  534.     lsr.b    #4,d0
  535.     beq.s    mt_vol3
  536.     add.b    d0,$13(a4)
  537.     cmp.b    #$40,$13(a4)
  538.     bmi.s    mt_vol2
  539.     move.b    #$40,$13(a4)
  540. mt_vol2    moveq    #0,d0
  541.     move.b    $13(a4),d0
  542.     move.w    d0,8(a5)
  543.     rts
  544.  
  545. mt_vol3    move.b    3(a4),d0
  546.     and.b    #$f,d0
  547.     sub.b    d0,$13(a4)
  548.     bpl.s    mt_vol4
  549.     clr.b    $13(a4)
  550. mt_vol4    moveq    #0,d0
  551.     move.b    $13(a4),d0
  552.     move.w    d0,8(a5)
  553.     rts
  554.  
  555. mt_com2    move.b    $2(a4),d0
  556.     and.b    #$f,d0
  557.     cmp.b    #$e,d0
  558.     beq.s    mt_filter
  559.     cmp.b    #$d,d0
  560.     beq.s    mt_pattbreak
  561.     cmp.b    #$b,d0
  562.     beq.s    mt_songjmp
  563.     cmp.b    #$c,d0
  564.     beq.s    mt_setvol
  565.     cmp.b    #$f,d0
  566.     beq.s    mt_setspeed
  567.     rts
  568.  
  569. mt_filter
  570.     move.b    3(a4),d0
  571.     and.b    #1,d0
  572.     asl.b    #1,d0
  573.     and.b    #$fd,$bfe001
  574.     or.b    d0,$bfe001
  575.     rts
  576.  
  577. mt_pattbreak
  578.     move.b    #1,mt_break
  579.     rts
  580.  
  581. mt_songjmp
  582.     move.b    #1,mt_break
  583.     move.b    3(a4),d0
  584.     subq.b    #1,d0
  585.     move.b    d0,mt_songpos
  586.     rts
  587.  
  588. mt_setvol
  589.     cmp.b    #$40,3(a4)
  590.     bls.s    mt_sv2
  591.     move.b    #$40,3(a4)
  592. mt_sv2    moveq    #0,d0
  593.     move.b    3(a4),d0
  594.     move.b    d0,$13(a4)
  595.     move.w    d0,8(a5)
  596.     rts
  597.  
  598. mt_setspeed
  599.     moveq    #0,d0
  600.     move.b    3(a4),d0
  601.     cmp.b    #$1f,d0
  602.     bls.s    mt_sp2
  603.     moveq    #$1f,d0
  604. mt_sp2    tst.w    d0
  605.     bne.s    mt_sp3
  606.     moveq    #1,d0
  607. mt_sp3    move.b    d0,mt_speed
  608.     rts
  609.  
  610. mt_amhandler
  611.     moveq    #3,d7
  612.     lea    mt_voice1,a6
  613.     lea    $dff0a0,a5
  614. mt_amloop
  615.     tst.w    30(a6)
  616.     beq    mt_anrp
  617.     move.w    34(a6),d0
  618.     mulu    #120,d0
  619.     add.l    mt_data2pt,d0
  620.     move.l    d0,a0
  621.     tst.w    38(a6)
  622.     beq    mt_anrp
  623.     cmp.w    #1,38(a6)
  624.     bne.s    mt_anat
  625.     move.w    32(a6),d0
  626.     cmp.w    8(a0),d0
  627.     beq.s    mt_aaeq
  628.     cmp.w    8(a0),d0
  629.     blt.s    mt_aaad
  630.     move.w    10(a0),d0
  631.     sub.w    d0,32(a6)
  632.     move.w    32(a6),d0
  633.     cmp.w    8(a0),d0
  634.     bgt    mt_anxt
  635.     move.w    8(a0),32(a6)
  636. mt_aaeq    move.w    #2,38(a6)
  637.     bra    mt_anxt
  638. mt_aaad    move.w    10(a0),d0
  639.     add.w    d0,32(a6)
  640.     move.w    32(a6),d0
  641.     cmp.w    8(a0),d0
  642.     blt    mt_anxt
  643.     move.w    8(a0),32(a6)
  644.     bra.s    mt_aaeq
  645. mt_anat    cmp.w    #2,38(a6)
  646.     bne.s    mt_ana2
  647.     move.w    32(a6),d0
  648.     cmp.w    12(a0),d0
  649.     beq.s    mt_a2eq
  650.     cmp.w    12(a0),d0
  651.     blt.s    mt_a2ad
  652.     move.w    14(a0),d0
  653.     sub.w    d0,32(a6)
  654.     move.w    32(a6),d0
  655.     cmp.w    12(a0),d0
  656.     bgt    mt_anxt
  657.     move.w    12(a0),32(a6)
  658. mt_a2eq    move.w    #3,38(a6)
  659.     bra    mt_anxt
  660. mt_a2ad    move.w    14(a0),d0
  661.     add.w    d0,32(a6)
  662.     move.w    32(a6),d0
  663.     cmp.w    12(a0),d0
  664.     blt    mt_anxt
  665.     move.w    12(a0),32(a6)
  666.     bra.s    mt_a2eq
  667. mt_ana2    cmp.w    #3,38(a6)
  668.     bne.s    mt_andc
  669.     move.w    32(a6),d0
  670.     cmp.w    16(a0),d0
  671.     beq.s    mt_adeq
  672.     cmp.w    16(a0),d0
  673.     blt.s    mt_adad
  674.     move.w    18(a0),d0
  675.     sub.w    d0,32(a6)
  676.     move.w    32(a6),d0
  677.     cmp.w    16(a0),d0
  678.     bgt.s    mt_anxt
  679.     move.w    16(a0),32(a6)
  680. mt_adeq    move.w    #4,38(a6)
  681.     move.w    20(a0),40(a6)
  682.     bra.s    mt_anxt
  683. mt_adad    move.w    18(a0),d0
  684.     add.w    d0,32(a6)
  685.     move.w    32(a6),d0
  686.     cmp.w    16(a0),d0
  687.     blt.s    mt_anxt
  688.     move.w    16(a0),32(a6)
  689.     bra.s    mt_adeq
  690. mt_andc    cmp.w    #4,38(a6)
  691.     bne.s    mt_anst
  692.     subq.w    #1,40(a6)
  693.     bpl.s    mt_anxt
  694.     move.w    #5,38(a6)
  695.     bra.s    mt_anxt
  696. mt_anst    move.w    24(a0),d0
  697.     sub.w    d0,32(a6)
  698.     bpl.s    mt_anxt
  699.     clr.l    30(a6)
  700.     clr.w    38(a6)
  701.     move.w    26(a6),$dff096
  702. mt_anxt    move.w    32(a6),d0
  703.     lsr.w    #2,d0
  704.     move.w    d0,8(a5)
  705.     move.w    28(a0),d0
  706.     add.w    d0,16(a6)
  707.     move.w    30(a0),d1
  708.     beq.s    mt_nvib
  709.     move.w    36(a6),d2
  710.     moveq    #0,d3
  711.     cmp.w    #360,d2
  712.     blt.s    mt_vibq
  713.     sub.w    #360,d2
  714.     moveq    #1,d3
  715. mt_vibq    lea    mt_amsinus,a2
  716.     muls    0(a2,d2.w),d1
  717.     asr.w    #7,d1
  718.     tst.w    d3
  719.     beq.s    mt_nvib
  720.     neg.w    d1
  721. mt_nvib    add.w    16(a6),d1
  722.     move.w    d1,6(a5)
  723.     move.w    32(a0),d0
  724.     add.w    d0,d0
  725.     add.w    d0,36(a6)
  726.     cmp.w    #720,36(a6)
  727.     blt.s    mt_anrp
  728.     sub.w    #720,36(a6)
  729. mt_anrp    lea    $10(a5),a5
  730.     lea    42(a6),a6
  731.     dbra    d7,mt_amloop
  732.  
  733.     lea    mt_noisewave,a0
  734.     move.w    #$7327,d0
  735.     moveq    #31,d1
  736. mt_nlop    move.b    d0,(a0)+
  737.     add.b    $dff007,d0
  738.     eor.w    #124,d0
  739.     rol.w    #3,d0
  740.     dbra    d1,mt_nlop
  741.     rts
  742.  
  743. mt_periods
  744.     dc.w    $358,$328,$2fa,$2d0,$2a6,$280,$25c,$23a,$21a,$1fc,$1e0
  745.     dc.w    $1c5,$1ac,$194,$17d,$168,$153,$140,$12e,$11d,$10d,$fe
  746.     dc.w    $f0,$e2,$d6,$ca,$be,$b4,$aa,$a0,$97,$8f,$87
  747.     dc.w    $7f,$78,$71,0
  748.  
  749. mt_data2pt    dc.l    0
  750. mt_speed    dc.b    6
  751. mt_counter    dc.b    0
  752. mt_pattpos    dc.w    0
  753. mt_songpos    dc.b    0
  754. mt_break    dc.b    0
  755. mt_dmacon    dc.w    0
  756. mt_samplestarts    ds.l    $1f
  757. mt_voice1    ds.w    13
  758.         dc.w    1
  759.         ds.w    7
  760. mt_voice2    ds.w    13
  761.         dc.w    2
  762.         ds.w    7
  763. mt_voice3    ds.w    13
  764.         dc.w    4
  765.         ds.w    7
  766. mt_voice4    ds.w    13
  767.         dc.w    8
  768.         ds.w    7
  769.  
  770. name    dc.b    "StarTrekker 1.2",0
  771.  
  772.  
  773.  
  774.     section    "chip",data,chip ; FIXME: This doesn't seem to work
  775.  
  776. mt_amwaveforms
  777.     dc.b    0,25,49,71,90,106,117,125
  778.     dc.b    127,125,117,106,90,71,49,25
  779.     dc.b    0,-25,-49,-71,-90,-106,-117
  780.     dc.b    -125,-127,-125,-117,-106
  781.     dc.b    -90,-71,-49,-25
  782.     dc.b    -128,-120,-112,-104,-96,-88,-80,-72,-64,-56,-48
  783.     dc.b    -40,-32,-24,-16,-8,0,8,16,24,32,40,48,56,64,72,80
  784.     dc.b    88,96,104,112,120
  785.     dc.b    -128,-128,-128,-128,-128,-128,-128,-128
  786.     dc.b    -128,-128,-128,-128,-128,-128,-128,-128
  787.     dc.b    127,127,127,127,127,127,127,127
  788.     dc.b    127,127,127,127,127,127,127,127
  789.  
  790. mt_noisewave
  791.     ds.b    32
  792.  
  793. mt_amsinus
  794.     dc.w    0,2,4,6,8,$b,$d,$f,$11,$14,$16,$18,$1a,$1c,$1e,$21
  795.     dc.w    $23,$25,$27,$29,$2b,$2d,$2f,$32,$34,$36,$38,$3a,$3c,$3e
  796.     dc.w    $3f,$41,$43,$45,$47,$49,$4b,$4d,$4e,$50,$52,$53,$55,$57
  797.     dc.w    $58,$5a,$5c,$5d,$5f,$60,$62,$63,$64,$66,$67,$68,$6a,$6b
  798.     dc.w    $6c,$6d,$6e,$6f,$71,$72,$73,$74,$74,$75,$76,$77,$78,$79
  799.     dc.w    $79,$7a,$7b,$7b,$7c,$7c,$7d,$7d,$7e,$7e,$7e,$7f,$7f,$7f
  800.     dc.w    $7f,$7f,$7f,$7f,$80,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7e,$7e
  801.     dc.w    $7e,$7d,$7d,$7c,$7c,$7b,$7b,$7a,$79,$79,$78,$77,$76,$75
  802.     dc.w    $74,$73,$72,$71,$6f,$6e,$6d,$6c,$6b,$6a,$68,$67,$66,$64
  803.     dc.w    $63,$62,$60,$5f,$5d,$5c,$5a,$58,$57,$55,$53,$52,$50,$4e
  804.     dc.w    $4d,$4b,$49,$47,$45,$43,$41,$40,$3e,$3c,$3a,$38,$36,$34
  805.     dc.w    $32,$2f,$2d,$2b,$29,$27,$25,$23,$21,$1e,$1c,$1a,$18,$16
  806.     dc.w    $14,$11,$f,$d,$b,$8,$6,$4,$2,0
  807.  
  808.     end
  809.